<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()
            + "://" + request.getServerName()
            + ":" + request.getServerPort()
            + path + "/";
%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" href="<%=basePath%>css/pintuer.css">
    <link rel="stylesheet" href="<%=basePath%>css/admin.css">
    <script src="<%=basePath%>js/jquery.js"></script>
    <script src="<%=basePath%>js/pintuer.js"></script>
</head>
<body>
<form method="post" action="">
    <div class="panel admin-panel">
        <div class="panel-head"><strong class="icon-reorder"> 会员管理</strong></div>
        <table class="table table-hover text-center">
            <tr style="font-family: 'Adobe 仿宋 Std R';font-size: 16px">
                <th width="12.5%">登录名</th>
                <th width="12.5%">昵称</th>
                <th width="12.5%">性别</th>
                <th width="12.5%">年龄</th>
                <th width="12.5%">邮箱</th>
                <th width="12.5%">状态</th>
                <th width="12.5%">创建时间</th>
                <th width="12.5%">操作</th>
            </tr>
            <tbody id="yibuDel">
                <c:forEach items="${allUser}" var="user">
                    <tr >
                        <td>${user.loginId}</td>
                        <td>${user.name}</td>
                        <td>${user.sex}</td>
                        <td>${user.age}</td>
                        <td>${user.email}</td>
                        <td>${user.state == 1?"<font color='green'>正常</font>":"<font color='red'>已注销</font>"}</td>
                        <td>${user.more2}</td>
                        <td><div class="button-group">
                            <a class="button border-main" href="#add" onclick="xiugaiUser('${user.id}')"><span class="icon-edit"></span> 修改</a>
                            <a class="button border-red" href="javascript:void(0)" onclick="del('${user.id}')"><span class="icon-trash-o"></span> 删除</a>
                        </div></td>
                    </tr>
                </c:forEach>
            </tbody>
        </table>
    </div>
</form>
<h1 hidden id="delfaile">${changeUser}</h1>
<script type="text/javascript">
    //提示
    $(document).ready(function () {
        var $tishi = $("#delfaile").text();
        if ($tishi != "" && $tishi != null){
            alert($tishi);
            $("#delfaile").html("");
        }
    })
//修改
    function xiugaiUser(aa){
        alert(aa + "这是修改");
        window.location.href="<%=basePath%>shixun/changeUser?userid=" + aa;
    }

//    删除
    function del(userId) {
        if (confirm("您确定要删除吗?")) {
            window.location.href="<%=basePath%>shixun/changeUserState?userId=" + userId;

            <%--$.getJSON("<%=basePath%>shixun/changeUserState",{userId:userId},function (result) {--%>
                <%--alert(result);--%>
                <%--if (result.length == 0){--%>
                    <%--alert("删除失败！");--%>
                <%--}else {--%>
                    <%--$("#yibuDel").html("");--%>
                    <%--for (var i = 0;i < result.length;i++){--%>
                        <%--result[i].createtime = (result[i].createtime).substring(0,10);--%>
                        <%--$("#yibuDel").append(--%>
                                <%--"<tr>" +--%>
                                <%--"<td>" + result[i].loginId + "</td>" +--%>
                                <%--"<td>" + result[i].name + "</td>" +--%>
                                <%--"<td>" + result[i].sex + "</td>" +--%>
                                <%--"<td>" + result[i].age + "</td>" +--%>
                                <%--"<td>" + result[i].email + "</td>" +--%>
                                <%--"<td>" + result[i].state  + "</td>" +--%>
                                <%--"<td>" + result[i].createtime + "</td>" +--%>
                                <%--"<td><div class='button-group'>" +--%>
                                <%--"<a class='button border-main' onclick='xiugaiUser(${user.id})'><span class='icon-edit'></span> 修改</a>" +--%>
                                <%--"<a class='button border-red' onclick='del(${user.id})'><span class='icon-trash-o'></span>删除</a>" +--%>
                                <%--"</div></td>" +--%>
                                <%--"</tr>"--%>
                        <%--)--%>
                    <%--}--%>
                <%--}--%>
            <%--})--%>
        }
    }

    $("#checkall").click(function () {
        $("input[name='id[]']").each(function () {
            if (this.checked) {
                this.checked = false;
            }
            else {
                this.checked = true;
            }
        });
    })

    function DelSelect() {
        var Checkbox = false;
        $("input[name='id[]']").each(function () {
            if (this.checked == true) {
                Checkbox = true;
            }
        });
        if (Checkbox) {
            var t = confirm("您确认要删除选中的内容吗？");
            if (t == false) return false;
        }
        else {
            alert("请选择您要删除的内容!");
            return false;
        }
    }

</script>
</body>
</html>